
import BaseElement from './base';
/**
 * 绘制长方形
 * @param {*} x
 * @param {*} y
 * @param {*} width
 * @param {*} height
 * @param {*} color
 */
let index = 1;
class CircleElement extends BaseElement {
	constructor(props) {
		const { x, y, r, } = props;
		if (typeof x === 'undefined' || typeof y === 'undefined' || typeof r === 'undefined') {
			throw new Error("参数不正确")
		}
		props.type = "CircleElement";
		super(props);
		this.id = `CircleElement_${index++}`;
	}

	drawSpecial() {
		this.canvas.ctx.beginPath();
		this.canvas.ctx.moveTo(this.x + this.r, this.y);
		this.canvas.ctx.arc(this.x, this.y, this.r, 2 * Math.PI, 0, true);
		if (this.text) {
			this.canvas.ctx.font = "16px Verdana";
			this.canvas.ctx.fillText(this.text, this.x - 20, this.y + 6);
		}
		this.canvas.ctx.closePath();
		this.canvas.ctx.stroke();
	}
	hover() {
		const args = Array.prototype.slice.call(arguments)
		super.hover.apply(this, args);
	}
	drug() {
		super.drug();
	}
}

export default CircleElement;